<template>
	<view>
	<!-- 	<view class="list flex align-center justify-center" v-for="(item,index) in list" :key="index" @click="goCourse(item.courseId,item.courseDetailsId)">
			<view class="list-box flex align-center justify-between">
				<view class="list-box-l">
					<image :src="item.titleImg" mode="aspectFill"></image>
				</view>
				<view class="list-box-r flex flex-wrap">
					<view class="list-box-r-title">
						{{item.title}}
					</view>
					<view class="list-box-r-jilu">
						看到{{item.courseDetailsName}}
					</view>
					<view class="list-box-r-new flex align-center justify-between">
						<view class="list-box-r-new-l">
							{{item.over==1?'完结':'更新'+item.courseDetailsCount+'集'}}
						</view>
						<view class="list-box-r-new-r">
							继续观看
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="" style="margin: 20rpx;" v-if="list.length > 0">
			<u-loadmore :status="status" />
		</view> -->
	<view v-if="list.length>0" class="itemTitle flex align-center justify-center">
		<view class="itemTitle-box flex align-center justify-between">
			<view class="itemTitle-box-l">
				最近观看
			</view>
			<view class="itemTitle-box-r" @click="goNav('/me/jilu/jilu')">
				更多
			</view>
		</view>
	</view>
	<view v-if="list.length>0" class="zuijin flex align-center justify-center">
		<view class="zuijin-box flex justify-between">
			<view class="zuijin-box-item" @click="goCourse(item.courseId,item.courseDetailsId)"
				v-for="(item,index) in list" :key="index">
				<view class="zuijin-box-item-img">
					<image :src="item.titleImg" mode="aspectFill"></image>
					<view class="zuijin-box-item-img-t" v-if="item.courseDetailsName">
						{{item.courseDetailsName}}
					</view>
				</view>
				<view class="zuijin-box-item-txt flex align-center flex-wrap">
					<view class="zuijin-box-item-txt-t">
						{{item.title}}
					</view>
					<view class="zuijin-box-item-txt-l" v-if="item.courseLabel">
						{{item.courseLabelText}}
					</view>
				</view>
			</view>
		</view>
	</view>
	<view v-if="zhuiju.length>0" class="itemTitle flex align-center justify-center">
		<view class="itemTitle-box flex align-center justify-between">
			<view class="itemTitle-box-l">
				我的追剧
			</view>
			<view class="itemTitle-box-r" @click="goNav('/me/jilu/histor')">
				更多
			</view>
		</view>
	</view>
	<view v-if="zhuiju.length>0" class="zuijin flex align-center justify-center">
		<view class="zuijin-box flex justify-between">
			<view @click="goCourse(item.courseId,item.courseDetailsId)" class="zuijin-box-item"
				v-for="(item,index) in zhuiju" :key="index">
				<view class="zuijin-box-item-img">
					<image :src="item.titleImg" mode="aspectFill"></image>
					<view class="zuijin-box-item-img-t" v-if="item.courseDetailsName">
						{{item.courseDetailsName}}
					</view>
				</view>
				<view class="zuijin-box-item-txt flex align-center flex-wrap">
					<view class="zuijin-box-item-txt-t">
						{{item.title}}
					</view>
					<view class="zuijin-box-item-txt-l" v-if="item.courseLabel">
						{{item.courseLabelText}}
					</view>
				</view>
			</view>
		</view>
	</view>
	
		<!-- <empty v-if="list.length == 0" title="暂无记录" /> -->
	</view>
</template>

<script>
	import empty from '../../components/empty.vue'
	export default {
		components:{
			empty
		},
		data() {
			return {
				status: 'loadmore',
				list:[],
				page:1,
				pages:1,
				limit:10,
				list: [],
				zhuiju: [],
			};
		},
		onShow() {
			// this.getList()
			if (uni.getStorageSync('token')) {
				this.newLook()
				this.myVideo()
				// this.myQianInfo()
			}
		},
		onPullDownRefresh() {
			this.page = 1
			this.getList()
		},
		onReachBottom() {
			if(this.page < this.pages){
				this.page += 1
				this.status = 'loading'
				this.getList()
			}else{
				this.status = 'nomore'
			}
		},
		methods:{
			//我的追剧
			myVideo() {
				let data = {
					page: 1,
					limit: 2,
					classify: 1, //1收藏 2点赞 3历史记录
				}
				this.$Request.getT('/app/courseCollect/selectByUserId', data).then(res => {
					if (res.code == 0) {
						this.zhuiju = res.data.records
					}
				})
			},
			//最近观看
			newLook() {
				let data = {
					page: 1,
					limit: 2,
					classify: 3, //1收藏 2点赞 3历史记录
				}
				this.$Request.getT('/app/courseCollect/selectByUserId', data).then(res => {
					if (res.code == 0) {
						this.list = res.data.records
						this.$nextTick(() => {
							this.videPage = 1
						})
					}
				})
			},
			// 跳转资源详情
			goCourse(e,courseDetailsId) {
				uni.navigateTo({
					url: '/me/detail/detail?id=' + e+'&courseDetailsId='+courseDetailsId
				})
			},
			//获取观看记录
			getList(){
				let data = {
					page:this.page,
					limit:this.limit,
					classify:1
				}
				this.$Request.getT('/app/courseCollect/selectByUserId',data).then(res=>{
					uni.stopPullDownRefresh()
					if(res.code == 0){
						this.pages = res.data.pages
						if(this.page < this.pages){
							this.status = 'loadmore'
						}else{
							this.status = 'nomore'
						}
						if(this.page == 1){
							this.list = res.data.records
						}else{
							this.list = [...this.list,...res.data.records]
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	// .list{
	// 	width: 100%;
	// 	height: auto;
	// 	margin-top: 20rpx;
	// 	.list-box{
	// 		width: 686rpx;
	// 		height: 100%;
	// 		background-color: #ffffff;
	// 		border-radius: 24rpx;
	// 	}
	// 	.list-box-l{
	// 		width: 150rpx;
	// 		height: 200rpx;
	// 		border-radius: 24rpx;
	// 		image{
	// 			width: 100%;
	// 			height: 100%;
	// 			border-radius: 24rpx;
	// 		}
	// 	}
	// 	.list-box-r{
	// 		width: calc(100% - 170rpx);
	// 		height: 200rpx;
	// 		padding: 20rpx;
	// 		.list-box-r-title{
	// 			width: 100%;
	// 			color: #2e2f33;
	// 			font-size: 32rpx;
	// 			font-weight: bold;
	// 		}
	// 		.list-box-r-jilu{
	// 			width: 100%;
	// 			color: #5074FF;
	// 			font-size: 28rpx;
	// 		}
	// 		.list-box-r-new{
	// 			width: 100%;
	// 			font-size: 28rpx;
	// 			.list-box-r-new-l{
	// 				color: #aeb2c1;
					
	// 			}
	// 			.list-box-r-new-r{
	// 				padding:10rpx 20rpx;
	// 				background-color: #5074FF;
	// 				color: #ffffff;
	// 				border-radius: 24rpx;
	// 			}
				
				
	// 		}
	// 	}
	// }
	page {
		background-color: #F5F7FF;
	}
	
	.itemTitle {
		width: 100%;
		height: auto;
		margin-top: 46rpx;
	
		.itemTitle-box {
			width: 686rpx;
			height: 100%;
	
		}
	
		.itemTitle-box-l {
			color: #333333;
			font-size: 32rpx;
			font-weight: bold;
		}
	
		.itemTitle-box-r {
			color: #999999;
			font-size: 28rpx;
	
		}
	}
	
	.zuijin {
		width: 100%;
		margin-top: 26rpx;
	
		.zuijin-box {
			width: 686rpx;
			height: 100%;
	
		}
	
		.zuijin-box-item {
			width: calc((686rpx - 20rpx) / 2);
			height: 100%;
		}
	
		.zuijin-box-item-img {
			width: 100%;
			height: 204rpx;
			border-radius: 24rpx 24rpx 0 0;
			position: relative;
	
			image {
				width: 100%;
				height: 100%;
				border-radius: 24rpx 24rpx 0 0;
			}
	
			.zuijin-box-item-img-t {
				position: absolute;
				bottom: 10rpx;
				right: 0;
				max-width: 80%;
				border-radius: 10rpx;
				background-color: rgba(51, 51, 51, 0.7);
				color: #FFFFFF;
				font-size: 22rpx;
				padding: 10rpx;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
	
			}
		}
	
		.zuijin-box-item-txt {
			width: 100%;
			height: 100rpx;
			background-color: #ffffff;
			border-radius: 0 0 24rpx 24rpx;
			align-content: center;
		}
	
		.zuijin-box-item-txt-t {
			width: 100%;
			padding: 0 20rpx;
			color: #333333;
			font-size: 30rpx;
			font-weight: bold;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
	
		}
	
		.zuijin-box-item-txt-l {
			width: 100%;
			padding: 0 20rpx;
			color: #999999;
			font-size: 22rpx;
		}
	}
	
	.title {
		width: 100%;
		padding-top: 30rpx;
	
		.title-box {
			width: 686rpx;
			background-color: #E5EAFF;
			border-radius: 24rpx;
			padding: 20rpx;
		}
	
		.title-box-title {
			font-size: 36rpx;
			font-weight: 700;
			color: #333;
		}
	
		.title-box-title-r {
			background-color: #5074FE;
			font-size: 26rpx;
			color: #ffffff;
			font-weight: 500;
			border-radius: 40rpx;
			padding: 20rpx 0;
			width: 166rpx;
		}
	
		.title-box-tishi {
			font-size: 24rpx;
			margin-top: 20rpx;
			color: #999999;
		}
	
		.title-box-day {
			width: 100%;
			margin-top: 30rpx;
	
			.title-box-day-item-lin {
				width: 30rpx;
				height: 4rpx;
				background: #bfbfbf;
				margin: 0 4rpx;
				margin-top: 30rpx;
			}
	
			.title-box-day-item-num {
				width: 60rpx;
				height: 60rpx;
				border-radius: 50%;
				// border: 1px solid #999999;
				color: #999999;
	
				image {
					width: 100%;
					height: 100%;
					border-radius: 50%;
				}
			}
	
			.title-box-day-item-day {
				width: 100%;
				text-align: center;
				font-size: 24rpx;
				margin-top: 20rpx;
			}
	
		}
	
		.title-box-btn {
			margin-top: 30rpx;
			width: 100%;
			border-radius: 44rpx;
			// background: linear-gradient(270deg, #fcae3a, #f15d25);
			background-color: #5074FF;
			color: #fff;
			text-align: center;
			padding: 22rpx 0;
			font-size: 32rpx;
		}
	}
</style>
